package com.hailiang.study.javase.java.util.stream;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Collectors_joining {
    /**
     * 输出结果：
     *      abbcccdd
     *      a, bb, ccc, dd
     *      'a, bb, ccc, dd'
     */
    @Test
    public void testJoining() {
        List<String> givenList = Arrays.asList("a", "bb", "ccc", "dd");

        System.out.println(givenList.stream().collect(Collectors.joining()));
        System.out.println(givenList.stream().collect(Collectors.joining(", ")));
        System.out.println(givenList.stream().collect(Collectors.joining(", ", "'", "'")));
    }
}
